package ch7;

public class Caculator {
	private String brand = "卡西欧";

	public int divide(int a, int b) throws RuntimeException {
		int c = 0;
		try {
			c = a / b;
			return c;
		} catch (Exception e) {
			System.out.println("除法出现问题：");
			e.printStackTrace();
			throw new RuntimeException(e);// 有异常抛出，异常后不需要返回值。

		}
	}

	public int divide3(int a, int b) throws MyException {
		int c = 0;
		try {
			c = a / b;
			return c;
		} catch (Exception e) {
			System.out.println("除法出现问题：");
			e.printStackTrace();
			throw new MyException(e);// 有异常抛出，异常后不需要返回值。

		}
	}

	public int divide2(int a, int b) throws Exception {
		int c = 0;
		try {
			c = a / b;
			return c;
		} catch (Exception e) {
			System.out.println("除法出现问题：");
			e.printStackTrace();
			throw e;// 有异常抛出，异常后不需要返回值。

		}
	}

	public int divide1(int a, int b) {
		int c = 0;
		try {
			c = a / b;
			return c;
		} catch (Exception e) {
			System.out.println("除法出现问题：");
			e.printStackTrace();

		}
		return c;
	}
}
